<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="t" tagdir="/WEB-INF/tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="error" uri="/WEB-INF/tags/ErrorTag.tld"%>
<t:basicTemplate pageTitle="SWIMv2 - ${userName} - Modify Personal Data">


	<jsp:attribute name="extrahead">
	
		<link rel='stylesheet' href='css/plainform.css' type='text/css' />
			
		<link rel='stylesheet' href='css/registrationStyle.css'
			type='text/css' />
			
		<script src="script/modifyPassword.js"></script>
		
		<!-- jqeury library, include in order to run the rest -->
	    <script type="text/javascript" src="script/jq.js"></script>
	   
	   <!--  states that when #custom_form is submitted, it has to be validated --> 
	   <script type="text/javascript" src="script/triggerValidation.js"></script>
	    
	    <!--  validate the form  -->
	    <script type="text/javascript" src="script/validate.js"></script> 
	</jsp:attribute>

	<jsp:body>
	
	<h1>Modify your personal data</h1>
	
	<div class="error-style">
		<error:errors error="${param.error}"></error:errors>
	</div>
	
	<c:if test="${param.status == 'password-changed'}">
		<div class="error-style">
		Password correctly changed!
		</div>
	</c:if>
	
	
	<form action="modifyData" method="POST" enctype="multipart/form-data"
			id="data_form">
	<ul>
        <li><label for="name">New name:</label></li>
        <li><input type="text" id="name" name="name"
					value="${currentName}"></li>
   		<li><label for="surname">New surname:</label></li>
        <li><input type="text" id="surname" name="surname"
					value="${currentSurname}"></li>
   		
   		<li><label for="email">New email:</label></li>
        <li><input type="text" id="email" name="email"
					value="${currentEmail}" data-validation="validate_email"></li>
      	
      	 <li><label for="City">City:</label></li>
         <li><input type="text" id="City" name="City"
					value="${city}" /></li>
		
		<li><label for="Street">Street:</label></li>
         <li><input type="text" id="Street" name="Street"
					value="${street}" /></li>
					
		<li><label for="number">Number:</label></li>
         <li><input type="text" id="Number" name="Number"
					value="${number}" /></li>
      	
      	 <li><label for="birthday">New birthday:</label></li>
         <li><input type="date" name="birthday" value="${birthDay}"></li>
      	
 		<li><label id="gender">Sex:</label></li>
		<li><input type="radio" name="sex" value="Male"
					<c:if test="${(not empty sex) and (sex=='M')}">
		  		checked	</c:if> />
				<span>Male</span></li>
						
		<li><input type="radio" name="sex" value="Female"
					<c:if test="${(not empty sex) and (sex=='F')}">
		  		checked	</c:if> />
		<span>Female</span></li>
      	
      	<li><br /></li>
      	
      	<li>Profile visibility</li>
      	
      	<li><input type="radio" name="visibility" id="public"
					value="Yes" <c:if test="${(isPublic==true)}">
		  		checked	</c:if>>
      	<label for="public">Public</label></li>
      	
      	<li><input type="radio" name="visibility" id="private"
					value="No" <c:if test="${(isPublic==false)}">
		  		checked	</c:if>>
      	<label for="private">Private</label></li>
      	
      	<li><br /></li>
      	
      	<li><label for="file">Image:</label></li>
        <li><input type="file" id="file" name="image"></li>
       	
       	<li><input type="submit" value="submit"></li>
	</ul>

	</form>
	<br />
	<br />
	<!-- password form! -->
	<form action="modifyPassword" method="POST" id="custom_form">
	
		<ul>
			<li><label for="password">Old password:</label></li>
            <li><input type="password" id="oldPassword"
					name="oldPassword" value=""></li>
      	
      		<li><label for="password">New password:</label></li>
            <li><input type="password" id="password" name="password"
					data-validation="validate_confirmation validate_length length4-15" /></li>
      	
        	<li><label for="password_confirm">Repeat new password:</label></li>
            <li><input type="password" id="password_confirmation"
					name="password_confirmation" value=""></li>
      		
      		<li><input type="submit" value="change"></li>
      		
      		<li>
	      		<div class="error-style">
	      			<error:errors error="${oldPassw}" />
	      		</div>
      		</li>
      	</ul>
	
	</form>

	<div class="error-style">
		<error:errors error="${param.fileError}" />
	</div>
	
    </jsp:body>
</t:basicTemplate>